/* 
	该文件专门用于配置一个一个的路由规则
*/
//引入各个路由组件
/* import Home from '@/pages/Home'
import Login from '@/pages/Login'
import Register from '@/pages/Register'
import Search from '@/pages/Search'
import Detail from '@/pages/Detail'
import AddCartSuccess from '@/pages/AddCartSuccess'
import Cart from '@/pages/Cart'
import Trade from '@/pages/Trade'
import Pay from '@/pages/Pay'
import PaySuccess from '@/pages/PaySuccess' */

//路由懒加载
const Home = ()=> import('@/pages/Home')
const Login = ()=> import('@/pages/Login')
const Register = ()=> import('@/pages/Register')
const Search = ()=> import('@/pages/Search')
const Detail = ()=> import('@/pages/Detail')
const AddCartSuccess = ()=> import('@/pages/AddCartSuccess')
const Cart = ()=> import('@/pages/Cart')
const Trade = ()=> import('@/pages/Trade')
const Pay = ()=> import('@/pages/Pay')
const PaySuccess = ()=> import('@/pages/PaySuccess')

export default [
	{
		name:'home',
		path:'/home',
		component:Home,
		meta:{
			isRequiredNav:true //控制导航（true代表必须展示导航）
		}
	},
	{
		name:'login',
		path:'/login',
		component:Login,
		meta:{
			isHiddenFooter:true //控制底部Footer（true代表隐藏Footer）
		}
	},
	{
		name:'register',
		path:'/register',
		component:Register,
		meta:{
			isHiddenFooter:true //控制底部Footer（true代表隐藏Footer）
		}
	},
	{
		name:'search',
		path:'/search',
		component:Search,
	},
	{
		name:'detail',
		path:'/detail/:id',
		component:Detail,
		props:true //将路由收到的所有params参数以props的形式传递给路由组件
	},
	{
		name:'addcartsuccess',
		path:'/addcartsuccess',
		component:AddCartSuccess,
	},
	{
		name:'cart',
		path:'/cart',
		component:Cart,
	},
	{
		name:'trade',
		path:'/trade',
		component:Trade,
		beforeEnter: (to, from, next) => {
			if(from.path === '/cart'){
				next()
			}else{
				next('/home')
			}
		}
	},
	{
		name:'pay',
		path:'/pay',
		component:Pay,
		beforeEnter: (to, from, next) => {
			if(from.path === '/trade'){
				next()
			}else{
				next('/home')
			}
		}
	},
	{
		name:'paysuccess',
		path:'/paysuccess',
		component:PaySuccess,
	},
	{
		path:'/',
		redirect:'/home'
	},
]